#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
//    Copyright (c) 2009 Elwyn Malethan
//
//    This file is part of SeemoreJ Example Web Application.
//
//    SeemoreJ Example Web Application is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    SeemoreJ Example Web Application is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.

//    You should have received a copy of the GNU General Public License
//    along with SeemoreJ Example Web Application.  If not, see <http://www.gnu.org/licenses/>.

package ${package}.app;

import static com.malethan.seemorej.SeemoreJ.*;
import com.malethan.seemorej.Accepts;
import static com.malethan.seemorej.Flash.*;
import static com.malethan.seemorej.HttpMethod.*;

/**
 * <p>Copyright &copy; 2009 Elwyn Malethan</p>
 */
public class HelloController {

    public void world() {
        request().setAttribute("message", "Hello, this is your friendly POJO controller");
    }

    @Accepts(method = POST)
    public void user() {
        String name = request().getParameter("username");
        if (name != null && name.length() > 0) {
            request().setAttribute("message", "Hello to you, " + name);
            request().setAttribute("username", name);
            flash(NOTICE, "Using name " + name);
        } else {
            flash(ERROR, "Please supply your name");
            world();
        }
        renderView("world");
    }
}
